package leetcode.tree;

import leetcode.tree.common.TreeNode;

/**
 * @author mazouri
 * @create 2021-05-04 21:30
 */
public class _404_sumOfLeftLeaves {
    public int sumOfLeftLeaves(TreeNode root) {
        if (root == null) return 0;

        int temp = 0;
        if (root.left != null && root.left.left == null && root.left.right == null) {
            temp = root.left.val;
        }

        int leftSum = sumOfLeftLeaves(root.left);
        int rightSum = sumOfLeftLeaves(root.right);

        return temp+leftSum+rightSum;
    }

}
